package myky.com.doctorapp.presenter;

import io.reactivex.disposables.Disposable;
import myky.com.doctorapp.api.ResponseTransformer;
import myky.com.doctorapp.api.schedulers.SchedulerHelper;
import myky.com.doctorapp.base.BasePresenterIm;
import myky.com.doctorapp.base.SimpleSubscribe;
import myky.com.doctorapp.contract.DoctoeTeamContract;
import myky.com.doctorapp.entity.DoctorTeamEntity;
import myky.com.doctorapp.model.DoctoeTeamModel;

public class DoctoeTeamPresenter extends BasePresenterIm<DoctoeTeamContract.View> implements DoctoeTeamContract.Presenter {

    DoctoeTeamModel doctoeTeamModel;

    public DoctoeTeamPresenter() {
        doctoeTeamModel=new DoctoeTeamModel();
    }

    @Override
    public void getTeamInfo(String version, String doctorId) {

        doctoeTeamModel.getDoctorTeamInfo(version, doctorId)
                .compose(ResponseTransformer.handleResult())
                .compose(SchedulerHelper.applySchedulers())
                .safeSubscribe(new SimpleSubscribe<DoctorTeamEntity>() {
                    @Override
                    protected void onSuccess(DoctorTeamEntity doctorTeamEntity) {

                        mView.showTeamInfo(doctorTeamEntity);

                        mView.showTeamMenber(doctorTeamEntity.getOtherdoctors());

                        mView.showScadule(doctorTeamEntity.getDoctorvisits());



                    }

                    @Override
                    protected void onFailed(String msg) {
                        mView.logCat(msg);
                    }

                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscription(d);
                    }
                });

    }
}
